/**
 * 2010(c) Copyright Oceansoft Information System Co.,LTD. All rights reserved.
 * <p>
 * Compile: JDK 1.6+
 * <p>
 * 版权所有(C)：江苏欧索软件有限公司
 * <p>
 * 公司名称：江苏欧索软件有限公司
 * <p>
 * 公司地址：中国苏州科技城青山路1号
 * <p>
 * 网址: http://www.oceansoft.com.cn
 * <p>
 * 版本: 苏州公安统一用户管理平台1.0
 * <p>
 * 作者: 孙炯
 * <p>
 * 文件名:SysOperMgrServiceImpl.java
 * <p>
 * 类产生时间: 2012-6-13 下午5:36:19
 * <p>
 * 负责人: 孙炯
 * 所在组 : 苏州公安统一用户管理平台
 * <p>
 * 所在部门: 电信/国土——技术二部
 * <p>
 * <p>
 */
package com.oceansoft.core.service.impl;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.oceansoft.core.common.constant.Constant;
import com.oceansoft.core.common.constant.ConstantMap;
import com.oceansoft.core.common.util.Pagination;
import com.oceansoft.core.dao.ISysOperMgrDao;
import com.oceansoft.core.domain.SysOperLog;
import com.oceansoft.core.domain.SysUser;
import com.oceansoft.core.service.ISysOperMgrService;

/**
 * 系统操作日志管理实现类
 * 
 * @author sunj
 * 
 */
@Service
public class SysOperMgrServiceImpl implements ISysOperMgrService {
	@Resource
	private ISysOperMgrDao sysOperMgrDao;

	@Override
	public Pagination<SysOperLog> findOperInfo(int pageIndex) {
		return sysOperMgrDao.findOperInfo(pageIndex);
	}

	@Override
	public Pagination<SysOperLog> findOperInfoByConditions(String userid, String uname, String module,
			String opertime1, String opertime2, int pageIndex) {
		return sysOperMgrDao.findOperInfoByConditions(userid, uname, module, opertime1, opertime2, pageIndex);
	}

	@Override
	public Pagination<SysOperLog> findOperInfoByConditions(String userid, String uname, String module, String snapdata,
			String opertime1, String opertime2, int pageIndex) {
		return sysOperMgrDao.findOperInfoByConditions(userid, uname, module, snapdata, opertime1, opertime2, pageIndex);
	}

	@Override
	public void insertSysOperLog(SysOperLog sysOperLog) {
		sysOperMgrDao.insertSysOperLog(sysOperLog);
	}

	@Override
	public void saveLog(HttpServletRequest request, String modualId, String content) {
		SysUser user = (SysUser) request.getSession().getAttribute(Constant.LOGIN_USER);
		SysOperLog log = new SysOperLog();
		if (null != user) {
			log.setModule(modualId);
			log.setModname(ConstantMap.modual(modualId));
			log.setUserid(user.getPoliceNum());
			log.setUname(user.getName());
			log.setContent(content);
			log.setDeptName(user.getDeptName());
			sysOperMgrDao.saveLog(log);
		}
	}

	@Override
	public void saveLog(SysUser user, String modualId, String content) {
		SysOperLog log = new SysOperLog();
		log.setModule(modualId);
		log.setModname(ConstantMap.modual(modualId));
		log.setUserid(user.getPoliceNum());
		log.setUname(user.getName());
		log.setContent(content);
		log.setDeptName(user.getDeptName());
		sysOperMgrDao.saveLog(log);
	}

	@Override
	public SysOperLog findOperInfoById(String logId) {
		return sysOperMgrDao.findOperInfoById(logId);
	}
}
